package com.WaVel.mapper;

import com.Emplyment.dto.StudyPathDto;
import com.Emplyment.entity.StudyPath;
import com.Emplyment.enumeration.OperationType;
import com.WaVel.annotation.AutoFill;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface StudyPathMapper {

    @Select("SELECT * FROM study_path WHERE subject = #{subject}")
    List<StudyPathDto> getStudyPath(String subject);

    @Select("SELECT * FROM study_path")
    List<StudyPath> getAllStudies();

    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into study_path(title, content, subject,createTime,updateTime) values (#{title},#{content},#{subject},#{createTime},#{updateTime})")
    void addStudy(StudyPath study);

    @AutoFill(value = OperationType.UPDATE)
    @Update("update study_path set title = #{title}, content = #{content}, subject = #{subject},updateTime = #{updateTime} where id = #{id}")
    void updateStudy(StudyPath study);

    @Delete("delete from study_path where id = #{id}")
    void deleteStudy(int id);

}
